import axios from '@/axios'

// 获取图书列表
export function getBookList(getBookForm) {
  return axios.get(`/public/book/getList/${getBookForm.current}/${getBookForm.size}/${getBookForm.orderType}`)
}

// 根据id获取图书
export function getBookDetailById(id) {
  return axios.get(`/public/book/getBookById/${id}`)
}

export function addNewBook(payload) {
  return axios({
    method: 'post',
    url: '/public/book/addBooks',
    data: payload
  })
}

export function updateBook(form) {
  return axios({
    method: 'post',
    url: '/public/book/updateBook',
    data: form
  })
}

// 根据图书类别
export function getCategory() {
  return axios.get(`public/category/getList`)
}

export function getCategoryDetailById(id) {
  return axios.get(`public/category/getCategoryById/${id}`)
}

export function updateCategory(form) {
  return axios({
    method: 'post',
    url: '/public/category/updateCategory',
    data: form
  })
}

export function deleteCategory(cId) {
  return axios.post(`public/category/deleteCategory/${cId}`)
}

export function addCategory(addForm) {
  return axios({
    method: 'post',
    url: '/public/category/addCategory',
    data: addForm
  })
}
